class p():
    def p1(x):
        if not x:
            return [x]
        else:
            res = []
            for i in range(len(x)):
                rest = x[:i] + x[i + 1:]
                for y in p.p1(rest):
                    res.append(x[i:i + 1] + x)
            return res

    def p2(x):
        if not x:
            yield x
        else:
            for i in range(len(x)):
                rest = x[:i] + x[i + 1:]
                for y in p.p2(rest):
                    yield x[i:i + 1] + x